package routes

import (
	v1_ctl "zpay/app/http/controllers/api/v1"
	"zpay/app/http/middlewares"

	"github.com/gin-gonic/gin"
)

func RegisterAPIRoutes(r *gin.Engine) {
	v1 := r.Group("/api/v1")
	{
		// 支付宝路由
		alipayGroup := v1.Group("/alipay")
		alipayGroup.Use(middlewares.LimitIP("5000-H"))
		{
			// 创建订单
			order_ctl := new(v1_ctl.OrderController)
			alipayGroup.POST("/orders", middlewares.LimitPerRoute("100-H"), order_ctl.Create)

			// 查询订单
			alipayGroup.GET("/orders/:order_no", order_ctl.Status)

			// 获取所有订单
			alipayGroup.GET("/orders/", order_ctl.Index)

			// 支付宝回调通知
			alipayGroup.POST("/orders/notify", order_ctl.Notify)
		}
	}
}
